@tool
class_name AdditionalEffect_ControlContextBehavior
extends AdditionalEffect

#region 属性
@export var behavior_info_dict:Dictionary[GameEnum.ContextBehaviorType,bool]
## 是否首先关闭所有behavior
@export var is_first_disable_all_behaviors:bool = true
#endregion
#region 字段
#endregion
#region 信号
#endregion

#region 基类方法
## 初始化
func init(args:Dictionary = {}):
	if super(args):
		return true
	return false
## 检查能否执行添加效果，默认为true
func can_excute() -> bool:
	return super()
## 执行添加效果
func excute() -> bool:
	if super():
		target = target as Entity
		var controller_component:ControllerComponent_SteeringBehavior = target.get_component(ControllerComponent_SteeringBehavior)
		if controller_component:
			if is_first_disable_all_behaviors:
				controller_component.control_all_behaviors(false)
			for behavior_type in behavior_info_dict.keys():
				controller_component.control_behavior_by_type(behavior_type,behavior_info_dict.get(behavior_type))
		return true
	else:
		return false
## 取消执行的效果
func cancel_excute() -> bool:
	if super():
		return true
	else:
		return false
#endregion
#region 公共方法
#endregion
#region 私有方法
#endregion
#region 生命周期函数
func _init() -> void:
	if Engine.is_editor_hint():
		resource_local_to_scene = true
#endregion
